package com.isunland.managesystem.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.isunland.managesystem.R;
import java.util.ArrayList;
import java.util.List;

public class EvaluateLogAdapter<T> extends BaseAdapter {

  private List<T> objects = new ArrayList<T>();
  @SuppressWarnings("all") private Context context;
  private LayoutInflater layoutInflater;

  public EvaluateLogAdapter(Context context, ArrayList<T> objects) {
    this.context = context;
    this.objects = objects;
    this.layoutInflater = LayoutInflater.from(context);
  }

  @Override public boolean isEmpty() {
    return false;
  }

  @Override public int getCount() {
    return objects.size();
  }

  @Override public T getItem(int position) {
    return objects.get(position);
  }

  @Override public long getItemId(int position) {
    return position;
  }

  @Override public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      convertView = layoutInflater.inflate(R.layout.adapter_evaluate_log, parent, false);
      convertView.setTag(new ViewHolder(convertView));
    }
    initializeViews(getItem(position), (ViewHolder) convertView.getTag());
    return convertView;
  }

  private void initializeViews(T object, ViewHolder holder) {
  }

  static class ViewHolder {
    @BindView(R.id.tv_userName) TextView tvUserName;
    @BindView(R.id.tv_workQuality) TextView tvWorkQuality;
    @BindView(R.id.tv_attitude) TextView tvAttitude;
    @BindView(R.id.tv_text) TextView tvText;
    @BindView(R.id.tv_date) TextView tvDate;

    ViewHolder(View view) {
      ButterKnife.bind(this, view);
    }
  }
}
